import { http } from "@/utils/http";

export type commonResult<T> = {
  code: number;
  msg: string;
  result: T;
};

export type infoType = {
  unityName: any;
  id?: number,
  nickname?: string,
  loginName?: string,
  password?: string,
  confirmPassword?: string,
  phone?: string,
  lastLoginTime?: string,
  lastLoginIP?: string,
  roleIds?: number,
  roleName?: string,
  allowPortal?: any[],
  authorizedUnityNum?: number,
  status?: number,
  isSuper?: number,
  unityId?: number,
  expireDate?:string,
  remark?: string,
  isPermanently?:number
}
export type infoTypeList = {
  data: infoType[];
  total: number;
};

const List = '/system/system/v2/manager/users';
const Url = '/system/system/v2/manager/user';
export const getList = (params?: object) => {
  return http.request<commonResult<infoTypeList>>("get", List, {
    params
  });
};
export const getInfo = (params?: object) => {
  return http.request<commonResult<infoType>>("get", Url, {
    params
  });
};
export const addInfo = (data?: object) => {
  return http.request<commonResult<any>>("post", Url, {
    data
  });
};
export const editInfo = (data?: object) => {
  return http.request<commonResult<any>>("put", Url, {
    data
  });
};
export const deleteInfo = (data?: object) => {
  return http.request<commonResult<any>>("delete", Url, {
    data
  });
};

/** 1.2.9.6 查询人员(下拉框) */
export const getUnitUserList = (params?: object) => {
  return http.request<commonResult<any>>("get", '/system/system/v2/manager/user-list', {
    params
  });
}
/** 1.2.9.8 设置用户超管状态 */
export const setSuper = (data?: object) => {
  return http.request<commonResult<any>>("put", '/system/system/v2/manager/super', {
    data
  });
}

/**1.2.1.11 获取公众号二维码 */
export const qrcode = (data?: object) => {
  return http.request<commonResult<any>>("get", '/system/system/v2/user/official-qrcode', {
    data
  });
};